package com.sec.etech.sys.util;

import com.sec.etech.sys.model.OperateHistory;
import com.sec.etech.sys.service.OperateHistoryService;
import org.openbpm.base.core.id.IdUtil;
import org.openbpm.base.core.util.AppUtil;

import java.util.Date;

public class HistoryUtil {
    public static OperateHistoryService getHistoryService(){
        return (OperateHistoryService)AppUtil.getBean("operateHistoryService");
    }

    // 兼容C# History方法
    // (new historys("PLAN", "tooling", String.valueOf(id))).set(his);
    public static void history(String platName, String platRange, String platId, String jsonHis) {
        OperateHistory history = new OperateHistory();
        history.setId(IdUtil.getSuid());
        history.setOpUser(ContextUtil.getCurrentUserId());
        history.setOpTime(new Date());
        history.setOpAction(platRange);
        history.setPlatName(platName);
        history.setPlatRange(platRange);
        history.setPlatId(platId);
        history.setJsonHistory(jsonHis);
        getHistoryService().save(history);
    }


}
